<?php

/* Steve Kitchen */

include('includes/session.inc');

$Title = _('Rebuild');

include('includes/header.inc');

/* Your webserver user MUST have read/write access to here,
otherwise you'll be wasting your time */

$PathToDefault = './locale/en_GB.utf8/LC_MESSAGES/messages.pot';
$FilesToInclude = '*.php includes/*.inc includes/*.php api/*.php reportwriter/languages/en_US/reports.php';
$xgettextCmd = 'xgettext --no-wrap --from-code=utf-8 -L php -o ' . $PathToDefault . ' ' . $FilesToInclude;

echo '<br />&nbsp;<a class="toplink" href="' . $RootPath . '/Z_poAdmin.php">' . _('Back to the translation menu') . '</a>';
echo '<br /><br />&nbsp;' . _('Utility page to rebuild the system default language file');

if (isset($_POST['submit'])) {

	echo '<br /><table><tr><td>';
	echo '<form method="post" action=' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '>';
	echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';

	/* Run xgettext to recreate the default message.po language file */

	prnMsg(_('Rebuilding the default language file ') . '.....<br />', 'info', ' ');

	system($xgettextCmd, $return);

	prnMsg(_('Done') . '. ' . _('You should now edit the default language file header') . '<br />', 'info', ' ');

	echo '<a class="toplink" href="' . $RootPath . '/Z_poAdmin.php">' . _('Back to the menu') . '</a></div>';
	echo '</form>';
	echo '</td></tr></table>';

} else {
	/* set up the page for editing */

	echo '<div class="centre">';
	echo '<br />';
	prnMsg(_('Every new language creates a new translation file from the system default one') . '.<br />' . _('This utility will recreate the system default language file by going through all the script files to get all the strings') . '.<br />' . _('This is not usually necessary but if done before a new language is created then that language will have any new or recently modified strings') . '.<br />' . _('Existing languages are not affected.') . '.', 'info', _('PLEASE NOTE'));
	echo '<br />';
	echo '<form method="post" action=' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '>';
	echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';

	echo '<input type="submit" name="submit" value="' . _('Proceed') . '" />&nbsp;&nbsp;';
	echo '</form>';
	echo '</div>';

}

include('includes/footer.inc');

?>